angular.module('app').config(['$stateProvider', '$urlRouterProvider', '$httpProvider', '$provide', function(
	$stateProvider,
	$urlRouterProvider,
	$httpProvider,
	$provide
) {

	/*添加拦截器*/
	$httpProvider.interceptors.push("zlInterceptor");
	/*拦截器结束*/

	/*配置httpProvider*/
	$httpProvider.defaults.transformRequest = function(obj) {
		var str = [];
		for(var p in obj) {
			str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
		}
		return str.join("&");
	}

	$httpProvider.defaults.headers.post = {
		'Content-Type': 'application/x-www-form-urlencoded'
	}
	/*配置httpProvider结束*/

	/*更改ng-click防重复点击*/
	$provide.decorator('ngClickDirective', ['$delegate', '$timeout', function($delegate, $timeout) {
		var original = $delegate[0].compile;
		var delay = 500;
		$delegate[0].compile = function(element, attrs, transclude) {
			var disabled = false;

			function onClick(evt) {
				if(disabled) {
					evt.preventDefault();
					evt.stopImmediatePropagation();
				} else {
					disabled = true;
					$timeout(function() {
						disabled = false;
					}, delay, false);
				}
			}
			element.on('click', onClick);
			return original(element, attrs, transclude);
		};
		return $delegate;
	}]);
	/*更改ng-click防重复点击 end*/

	/*禁止ios双击页面上移*/
	var iLastTouch = null; //缓存上一次tap的时间
	if(mui.os.ios) {
		document.body.addEventListener('touchend', function(event) {
			var iNow = new Date()
				.getTime();
			iLastTouch = iLastTouch || iNow + 1 /** 第一次时将iLastTouch设为当前时间+1 */ ;
			var delta = iNow - iLastTouch;
			if(delta < 500 && delta > 0) {
				event.preventDefault();
				return false;
			}
			iLastTouch = iNow;
		}, false);
	}
	/*禁止ios双击页面上移 end*/

	/*路由配置开始*/
	$urlRouterProvider.otherwise('home')
	$stateProvider.state('home', {
			url: '/home',
			templateUrl: 'views/home.html', //首页-精选
			controller: 'homeCtrl'
		}).state('user', {
			url: '/user',
			templateUrl: 'views/user.html', //首页-资产
			controller: 'userCtrl',
			islogin: true
		}).state('all', {
			url: '/all',
			templateUrl: 'views/all.html', //首页-理财
			controller: 'allCtrl',
		})
		.state('more', {
			url: '/more',
			templateUrl: 'views/more/more.html', //更多
			controller: 'moreCtrl',
		}).state('productInfo', {
			url: '/all/{productId}',
			templateUrl: 'views/product/product_info.html', //资产详情
			controller: 'productCtrl'
		}).state('productDetails', {
			url: '/productDetails/{debtId}',
			templateUrl: 'views/product/product_details.html', //资产详情
			controller: 'productCtrl'
		}).state('bondList', {
			url: '/bondList/{assetsId}/{type}',
			templateUrl: 'views/product/bond_list.html', //债券列表
			controller: 'productCtrl'
		}).state('Increase', {
			url: '/Increase/{assetsId}/{type}',
			templateUrl: 'views/assets/Increase.html', //加息券详情
			controller: 'assetsCtrl'
		}).state('fxfs', {
			url: '/fxfs/{assetsId}',
			templateUrl: 'views/product/product_fxfs.html', //风险分散
			controller: 'productCtrl'
		}).state('CpFxfs', {
			url: '/CpFxfs/{assetsId}',
			templateUrl: 'views/product/product_CpFxfs.html', //产品风险分散
			controller: 'productCtrl'
		}).state('productJs', {
			url: '/product/productJs',
			templateUrl: 'views/product/productJs.html', //产品介绍
			controller: 'productCtrl'
		}).state('productFx', {
			url: '/product/productFx',
			templateUrl: 'views/product/productFx.html', //风险告知书
			controller: 'productCtrl'
		}).state('risk_proposal', {
			url: '/product/risk_proposal',
			templateUrl: 'views/product/risk_proposal.html', //安全等级和投资建议
			controller: 'productCtrl'
		})
		.state('regular', {
			url: '/assets/regular',
			templateUrl: 'views/assets/regular.html', //我的定期
			controller: 'assetsCtrl',
			islogin: true
		}).state('current', {
			url: '/assets/current',
			templateUrl: 'views/assets/current.html', //我的活期
			controller: 'assetsCtrl',
			islogin: true
		}).state('disperse', {
			url: '/assets/disperse',
			templateUrl: 'views/assets/disperse.html', //我的散标
			controller: 'assetsCtrl',
			islogin: true
		}).state('disperse_details', {
			url: '/assets/disperse_details',
			templateUrl: 'views/assets/disperse_details.html', //我的散标-资产详情
			controller: 'assetsCtrl',
			islogin: true
		}).state('distribution', {
			url: '/assets/distribution',
			templateUrl: 'views/assets/distribution.html', //资产分布
			controller: 'assetsCtrl',
			islogin: true
		}).state('register', {
			url: '/register',
			templateUrl: 'views/users/register.html', //注册校验
			controller: 'userCtrl'
		}).state('register_code', {
			url: '/register_code',
			templateUrl: 'views/users/register_code.html', //注册
			controller: 'userCtrl'
		}).state('login', {
			url: '/login',
			templateUrl: 'views/users/login.html', //登录
			controller: 'userCtrl'
		}).state('SetLoginPassword', {
			url: '/SetLoginPassword',
			templateUrl: 'views/users/SetLoginPassword.html', //设置登录密码
			controller: 'userCtrl'
		}).state('Realname', {
			url: '/Realname',
			templateUrl: 'views/users/Realname.html', //实名认证
			controller: 'userCtrl',
			islogin: true
		}).state('BindBank', {
			url: '/BindBank',
			templateUrl: 'views/users/BindBank.html', //绑定银行卡
			controller: 'userCtrl',
			islogin: true
		}).state("SetTradePassword", {
			url: "/SetTradePassword", //设置交易密码
			templateUrl: "views/users/SetTradePassword.html",
			controller: 'userCtrl',
			islogin: true
		}).state("PayOne", {
			url: "/pay/one", //充值第一步
			templateUrl: 'views/pay/pay_one.html',
			controller: 'payCtrl',
			islogin: true
		}).state("PayTwoCode", {
			url: "/pay/twoCode", //充值第二步-验证码界面
			templateUrl: 'views/pay/pay_two_code.html',
			controller: 'payCtrl',
			islogin: true
		}).state("PayTwoPwd", {
			url: "/pay/twoPwd", //充值第二步-密码界面
			templateUrl: 'views/pay/pay_two_pwd.html',
			controller: 'payCtrl',
			islogin: true
		}).state("PayThree", {
			url: "/pay/three", //充值第三部-订单详情
			templateUrl: 'views/pay/pay_three.html',
			controller: 'payCtrl',
			islogin: true
		}).state("about", {
			url: "/about", //关于我们
			templateUrl: 'views/about/index.html',
			controller: 'aboutCtrl'
		}).state("help", {
			url: "/help", //帮助中心
			templateUrl: 'views/help/index.html',
			controller: 'helpCtrl'
		}).state("helpSafe", {
			url: "/help/safe", //帮助中心|账户安全
			templateUrl: 'views/help/safe.html',
			controller: 'helpCtrl'
		}).state("helpBank", {
			url: "/help/bank", //帮助中心|银行卡
			templateUrl: 'views/help/bank.html',
			controller: 'helpCtrl'
		}).state("helpTou", {
			url: "/help/tou", //帮助中心|投资
			templateUrl: 'views/help/touzi.html',
			controller: 'helpCtrl'
		}).state("helpTx", {
			url: "/help/tx", //帮助中心|提现
			templateUrl: 'views/help/tixian.html',
			controller: 'helpCtrl'
		}).state("helpLing", {
			url: "/help/ling", //帮助中心|灵活赚和智投资
			templateUrl: 'views/help/linghuo.html',
			controller: 'helpCtrl'
		}).state("helpOther", {
			url: "/help/other", //帮助中心|其他
			templateUrl: 'views/help/other.html',
			controller: 'helpCtrl'
		}).state("buy", {
			url: "/buy/{type}", //购买
			templateUrl: 'views/buy/index.html',
			controller: 'buyCtrl',
			islogin: true
		}).state("confirmBuy", {
			url: "/buy/confirmBuy/", //确认购买|交易密码
			templateUrl: 'views/buy/confirm_buy.html',
			controller: 'buyCtrl',
			islogin: true
		}).state("confirmBuyCode", {
			url: "/buy/confirmBuyCode/", //确认购买|验证码
			templateUrl: 'views/buy/confirm_buy_code.html',
			controller: 'buyCtrl',
			islogin: true
		}).state("buyInfo", {
			url: "/buy/buyInfo/", //订单详情
			templateUrl: 'views/buy/buy_info.html',
			controller: 'buyCtrl',
			islogin: true
		}).state("confirmOrder", {
			url: "/buy/confirmOrder/", //订单确认
			templateUrl: 'views/buy/confirm_Order.html',
			controller: 'buyCtrl',
			islogin: true
		}).state("Coupon", {
			url: "/buy/Coupon/", //优惠券
			templateUrl: 'views/buy/Coupon.html',
			controller: 'buyCtrl',
			islogin: true
		}).state("user_coupon", {
			url: "/assets/redList/", //资产优惠券列表
			templateUrl: 'views/assets/redList.html',
			controller: 'userCtrl',
			islogin: true
		}).state("redList_history", {
			url: "/assets/redList_history/", //资产优惠券列表
			templateUrl: 'views/assets/redList_history.html',
			controller: 'userCtrl',
			islogin: true
		}).state("RecordList", {
			url: "/assets/RecordList/", //交易记录
			templateUrl: 'views/assets/RecordList.html',
			controller: 'assetsCtrl',
			islogin: true
		}).state("OrderDetails", {
			url: "/assets/OrderDetails/{order_id}/{product_type_pid}/{iswallet}/{amount}", //订单详情
			templateUrl: 'views/assets/Order_details.html',
			controller: 'assetsCtrl',
			islogin: true
		}).state("Expired", {
			url: "/assets/Expired", //定期已到期
			templateUrl: 'views/assets/Expired.html',
			controller: 'assetsCtrl',
			islogin: true
		}).state("regular_details", {
			url: "/assets/regular_details", //定期资产详情
			templateUrl: 'views/assets/regular_details.html',
			controller: 'assetsCtrl',
			islogin: true
		}).state("current_details", {
			url: "/assets/current_details", //活期资产详情
			templateUrl: 'views/assets/current_details.html',
			controller: 'assetsCtrl',
			islogin: true
		}).state("current_attorn", {
			url: "/assets/current_attorn", //活期转让
			templateUrl: 'views/assets/current_attorn.html',
			controller: 'assetsCtrl',
			islogin: true
		}).state("current_attorn_details", {
			url: "/assets/current_attorn_details", //活期转让详情
			templateUrl: 'views/assets/current_attorn_details.html',
			controller: 'assetsCtrl',
			islogin: true
		}).state("current_attorn_list", {
			url: "/assets/current_attorn_list", //转让中
			templateUrl: 'views/assets/current_attorn_list.html',
			controller: 'assetsCtrl',
			islogin: true
		}).state("profit", {
			url: "/assets/profit", //收益
			templateUrl: 'views/assets/Profit.html',
			controller: 'assetsCtrl',
			islogin: true
		}).state("profit_details", {
			url: "/assets/profit_details", //收益列表
			templateUrl: 'views/assets/Profit_details.html',
			controller: 'assetsCtrl',
			islogin: true
		}).state("wallet", {
			url: "/assets/wallet", //钱包
			templateUrl: 'views/assets/wallet.html',
			controller: 'assetsCtrl',
			islogin: true
		}).state("collect_details", {
			url: "/assets/collect_details", //收支明细
			templateUrl: 'views/assets/collect_details.html',
			controller: 'assetsCtrl',
			islogin: true
		}).state("cash", {
			url: "/assets/cash", //提现
			templateUrl: 'views/assets/cash.html',
			controller: 'assetsCtrl',
			islogin: true
		}).state("cash_confirm", {
			url: "/assets/cash_confirm", //提现确认
			templateUrl: 'views/assets/cash_confirm.html',
			controller: 'assetsCtrl',
			islogin: true
		}).state("cash_Order", {
			url: "/assets/cash_Order", //提现订单详情
			templateUrl: 'views/assets/cash_Order.html',
			controller: 'assetsCtrl',
			islogin: true
		}).state('usercore', {
			url: '/more/usercore',
			templateUrl: 'views/more/user_core.html', //个人中心
			controller: 'moreCtrl',
			islogin: true
		}).state('userbank', {
			url: '/more/userbank',
			templateUrl: 'views/more/user_bank.html', //银行卡
			controller: 'moreCtrl',
			islogin: true
		}).state("EditLoginPwd", {
			url: "/more/EditLoginPwd", //修改登录密码
			templateUrl: 'views/more/user_EditLoginPwd.html',
			controller: 'moreCtrl',
			islogin: true
		}).state("EditTradePwd", {
			url: "/more/EditTradePwd", //修改交易密码
			templateUrl: 'views/more/user_EditTradePwd.html',
			controller: 'moreCtrl',
			islogin: true
		}).state("BackLoginPwd", {
			url: "/more/BackLoginPwd", //找回登录密码
			templateUrl: 'views/more/user_BackLoginPwd.html',
			controller: 'moreCtrl',
		}).state("BackTradePwd", {
			url: "/more/BackTradePwd", //找回交易密码
			templateUrl: 'views/more/user_BackTradePwd.html',
			controller: 'moreCtrl',
			islogin: true
		}).state('feedback', {
			url: '/more/feedback',
			templateUrl: 'views/more/feedback.html', //意见反馈
			controller: 'moreCtrl',
		}).state('product_details_new', {
			url: '/product_details_new/{debtId}',
			templateUrl: 'views/product/product_details_new.html', //项目详情(新)
			controller: 'productCtrl',
		}).state('EditPhone', {
			url: '/more/EditPhone',
			templateUrl: 'views/more/user_EditPhone.html', //修改预留手机号
			controller: 'moreCtrl',
		}).state('ValidatePhone', {
			url: '/more/ValidatePhone',
			templateUrl: 'views/more/user_ValidatePhone.html', //验证预料手机
			controller: 'moreCtrl',
		}).state('validateRealname', {
			url: '/more/validateRealname',
			templateUrl: 'views/more/user_validateRealname.html', //验证身份
			controller: 'moreCtrl',
		}).state('BindNew', {
			url: '/more/BindNew',
			templateUrl: 'views/more/user_BindNew.html', //绑定新号
			controller: 'moreCtrl',
		}).state('bankList', {
			url: '/more/bankList',
			templateUrl: 'views/more/bankList.html', //银行卡列表
			controller: 'moreCtrl',
		}).state('editBank', {
			url: '/more/editBank',
			templateUrl: 'views/more/editbank.html', //更换银行卡
			controller: 'moreCtrl',
		}).state('discount', {
			url: '/buy/discount/',
			templateUrl: 'views/buy/discount.html', //优惠券(新)
			controller: 'buyCtrl',
		})

}])